home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14292 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.logicon.com!newsmaster@klee
  2. From: kkolda@logicon.com (Kenneth D. Kolda)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: strstream destruction
  5. Date: 29 Mar 1996 20:24:00 GMT
  6. Organization: Logicon Operating Systems
  7. Message-ID: <4jhgt0$17f@piper.logicon.com>
  8. References: <315AD92C.726D@itd.ssb.com>
  9. NNTP-Posting-Host: 137.51.122.161
  10. Mime-Version: 1.0
  11.  
  12. In article <315AD92C.726D@itd.ssb.com>, chandpk@itd.ssb.com says...
  13. >
  14. >hi,
  15. >        i plan to use ostrstream to create some strings , i would
  16. >like to pass the string created as a char * by calling ostrstream.str(). 
  17. >how do i free the memory allocated can i just call delete on the char *
  18. >returned by ostrstream.str().
  19. >
  20. >thanks.
  21. >pramod.
  22. >-- 
  23. >
  24. >
  25. >        The butler walked in , a solemn procession of one.
  26. >                                        -P.G.Wodehouse
  27.  
  28.  
  29. As long as this is a "dynamic" ostrstream, i.e. you do not provide the 
  30. character buffer in the constructor, then when you recieve the char* from 
  31. the ostrstream::str() method, you should delete the result using the 
  32. "delete[]" operator.
  33.  
  34. Ken Kolda
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.     ostrstream MyStream;
  52.  
  53.